new const PLUGINNAME[] = "Drop all weapons when you die"
new const VERSION[] = "0.1"
new const AUTHOR[] = "JGHG"
/*
Copyleft by Johnny got his gun
http://www.amxmodx.org/forums/viewtopic.php?p=22368
*/

#include <amxmodx>

// Defines
#define NROFITEMS 34

// Globals
new const WEAPONSTRINGS[NROFITEMS][] = {
	"",						// 0 First should be empty
	"weapon_p228",
	"weapon_shield",
	"weapon_scout",
	"weapon_hegrenade",
	"weapon_xm1014",
	"",						// 6 C4 CSW_C4
	"weapon_mac10",
	"weapon_aug",
	"weapon_smokegrenade",
	"weapon_elite",
	"weapon_fiveseven",
	"weapon_ump45",
	"weapon_sg550",
#if defined (NO_STEAM)
	"",						// 14 empty in CS 1.5
	"",						// 15 empty in CS 1.5
#else
	"weapon_galil",			// 14
	"weapon_famas",			// 15
#endif
	"weapon_usp",
	"weapon_glock18",
	"weapon_awp",
	"weapon_mp5navy",
	"weapon_m249",
	"weapon_m3",
	"weapon_m4a1",
	"weapon_tmp",
	"weapon_g3sg1",
	"weapon_flashbang",
	"weapon_deagle",
	"weapon_sg552",
	"weapon_ak47",
	"",						// 27 knife CSW_KNIFE
	"weapon_p90",
	"item_kevlar",
	"item_assaultsuit",
	"item_thighpack"
}

// Functions
public death_event() {
	new dying = read_data(2)
	new name[33]
	get_user_name(dying, name, 32)
	//server_print("%d (%s) is dying.", dying, name)
	if (!dying)
		return PLUGIN_CONTINUE

	new weapons[32], weaponsInList // , buffer[1024] = "You died with these weapons:<BR>"

	get_user_weapons(dying, weapons, weaponsInList)

	for (new i = 0; i < weaponsInList; i++) {
		if (weapons[i] != CSW_KNIFE && weapons[i] != CSW_C4) {
			engclient_cmd(dying, "drop", WEAPONSTRINGS[weapons[i]])
			//server_print("%d drops: ^"%s^"", dying, WEAPONSTRINGS[weapons[i]])
		}
	}

	return PLUGIN_CONTINUE
}

public plugin_init() {
	register_plugin(PLUGINNAME, VERSION, AUTHOR)
	register_event("DeathMsg", "death_event", "a")
}